﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Alos.Entity;
using Alos.Common;
using Alos.IRepository;
using Alos.IService;
using PetaPoco;

namespace Alos.Service
{
    public class ReExamSubmitService : BaseService<ReExamSubmit>, IReExamSubmitService
    {
        IReExamSubmitRepository ReExamSubmitRepository;

        public ReExamSubmitService(IReExamSubmitRepository _ReExamSubmitRepository)
        {
            ReExamSubmitRepository = _ReExamSubmitRepository;
        }
        /// <summary>
        /// 添加学生试题答题详情记录表
        /// </summary>
        /// <param name="ReExamSubmit">学生试题答题详情记录表</param>
        /// <returns></returns>
        public bool CreateReExamSubmit(ReExamSubmit ReExamSubmit)
        {
            return ReExamSubmitRepository.CreatReExamSubmit(ReExamSubmit);
        }
        /// <summary>
        /// 统计学生课堂测验提交
        /// </summary>
        /// <param name="ExamID">测验编码</param>       
        /// <returns></returns>
        public dynamic GetReExamSubmitByExamID(string ExamID)
        {
            return ReExamSubmitRepository.GetReExamSubmitByExamID(ExamID);
        }
        /// <summary>
        /// 修改学生课堂测验提交表
        /// </summary>
        /// <param name="StudentID">学生ID</param>
        /// <param name="ExamID">课堂测验ID</param>
        /// <returns></returns>
        public bool UpdateReExamSubmit(int StudentID, string ExamID)
        {

            return ReExamSubmitRepository.UpdateReExamSubmit(StudentID, ExamID);
        }

        /// <summary>
        /// 添加课堂测试答题记录（课堂测验提交表）
        /// </summary>
        /// <param name="lRes"></param>
        /// <returns></returns>
        public bool Add(ReExamSubmit res)
        {
            res.EndTime = DateTime.Now;
            res.EndPiont = (int)(DateTime.Now - new DateTime(res.BeginTeachingTime)).TotalMinutes;
            res.RecordTime = DateTime.Now;
            return  ReExamSubmitRepository.Add(res);
        }

    }
}
